$(document).ready(function() {
    jQuery.validator.setDefaults({
        debug: true,
        success: "valid"
    });
    $('#form-info').validate({
        rules: {
            "email": {
                required: true,
                email: true
            },
            "nombre": {
                required: true
            },
            "apellido": {
                required: true
            }
        }
    });
});
function actualizarDatos() {
    if (!$('#form-info').valid())
        return;
    $.blockUI({
        message: 'Un momento por favor.'
    });
    $.ajax({
        url: '/academico/usuario/savemyaccount',
        type: 'post',
        dataType: 'json',
        data: {
            'nombre': $('#nombre').val(),
            'apellido': $('#apellido').val(),
            'email': $('#email').val()
        },
        success: function(data) {
            if (data.response === "success") {
                alertdiv('#div-alert', '<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Datos actualizados correctamente</div>');
            } else {
                alertdiv('#div-alert', '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><strong>Error! </strong>' + data.message + '</div>');
            }
            $.unblockUI();
        },
        error: function(a, b, c) {
            alertdiv('#div-alert', '<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><strong>Error!</strong> Ocurrio un error inesperado</div>');
            $.unblockUI();
        }
    });
}